var jsload = {
	loading: false,
	q: [],
	add: function(url) {
		this.q[this.q.length] = url;
		this.loadjs();
	},
	loadjs: function() {
		var url;
		var loadings = [];
		if ( !this.loading && this.q.length ) {
			url = this.q[0];
			this.loading = true;
		} else {
			return;
		}

		var ready = function(s) {
			if ( s.readyState == 'loaded' || s.readyState == 'complete' ) done();
		};

		var done = function() {
			loadings.splice(0, 1);
			if ( !loadings.length ) {
				jsload.q.splice(0, 1);
				jsload.loading = false;
				jsload.loadjs();
			}
		};

		if ( typeof url == 'string' ) url = [url];

		for ( var i = 0; i<url.length; i++ ) {
			loadings[i] = true;
			var src = url[i];
			var s = document.createElement('script');
			s.type = "text/javascript";
			s.onreadystatechange = function(s) { return function() { ready(s) } }(s);
			s.onerror = s.onload = done;
			s.src = src;
			document.getElementsByTagName('head')[0].appendChild(s);
		}
	}
};